package ro.prjmanager.web.actions;

import net.sourceforge.stripes.action.HandlesEvent;
import net.sourceforge.stripes.action.Resolution;
import net.sourceforge.stripes.action.RedirectResolution;
import net.sourceforge.stripes.action.ForwardResolution;

public abstract class NomenclatorAction<M> extends GenericAction<M>{
     @HandlesEvent("create")
    public Resolution create(){
        if(create==null)
            return null;
        Resolution ret;
        if(create.redirect())
            ret=new RedirectResolution(create.resource());
        else ret=new ForwardResolution(create.resource());
        M entity=castFromWeb();
        create(entity);
        return ret;
    }

    protected abstract M castFromWeb();

    protected abstract void castFromModel(M model);
}
